package com.yc.bos.web.action;

import com.yc.bos.model.Role;
import com.yc.bos.service.IRoleService;
import com.yc.bos.web.action.base.BaseAction;
import org.springframework.beans.factory.annotation.Autowired;

import java.io.IOException;
import java.util.List;

public class RoleAction extends BaseAction<Role> {

    private String functionIds;
    public void setFunctionIds(String functionIds) {
        this.functionIds = functionIds;
    }
   @Autowired
    private IRoleService roleService;

    @Override
    public String save() {
        roleService.save(getModel(),functionIds);
        return NONE;
    }

    @Override
    public String update() {
        return null;
    }

    @Override
    public String delete() throws IOException {
        return null;
    }

    @Override
    public String list() {
        return null;
    }

    public  void pageQuery() throws IOException {
        pd.setCurrentPage(page);
        pd.setPageSize(rows);
        roleService.pageQuery(pd);
        responseJson(pd,new String[]{"currentPage","pageSize","detachedCriteria","users","functions"});
    }
    public void listJson() throws IOException {
        List<Role> roles=roleService.findAll();
        responseJson(roles,new String[]{"users","functions"});
    }

}
